package yqt.com.cnki.dao.impl;

import cnki.tpi.kbatis.sqlsession.SqlSession;
import cnki.tpi.kbatis.utils.DataSourceUtil;
import org.springframework.stereotype.Repository;
import yqt.com.cnki.bo.QKYDBo;
import yqt.com.cnki.dao.IQKYDDao;
import yqt.com.cnki.po.KeyValuePo;
import yqt.com.cnki.po.QKYDPo;

import java.util.List;

/**
 * Description:
 *
 * @author BaiGe
 * @date: 2021/11/12 14:33
 * @Version 1.0
 */
@Repository
public class QKYDDaoImpl implements IQKYDDao {

    @Override
    public List<QKYDPo> getQKYD_Index() {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "yqt.com.cnki.dao.IQKYDDao.getQKYD_Index";
        return sqlSession.selectList(statementId, null, false);
    }

    @Override
    public List<KeyValuePo> getYear_Chinese() {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "yqt.com.cnki.dao.IQKYDDao.getYear_Chinese";
        return sqlSession.selectList(statementId, null, false);
    }

    @Override
    public List<KeyValuePo> getSort_English() {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "yqt.com.cnki.dao.IQKYDDao.getSort_English";
        return sqlSession.selectList(statementId, null, false);
    }

    @Override
    public List<QKYDPo> complexSearchQKYD_List(QKYDBo qkydBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "yqt.com.cnki.dao.IQKYDDao.complexSearchQKYD_List";
        return sqlSession.selectList(statementId, qkydBo, false);
    }

    @Override
    public long complexSearchQKYD_Count(QKYDBo qkydBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "yqt.com.cnki.dao.IQKYDDao.complexSearchQKYD_Count";
        return sqlSession.getCount(statementId, qkydBo);
    }



    @Override
    public QKYDPo getQKYDPoById(QKYDPo qkydPo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "yqt.com.cnki.dao.IQKYDDao.getQKYDPoById";
        return sqlSession.selectOne(statementId, qkydPo, false);
    }

    @Override
    public String getQKYDFileBasePath(String realDbCode) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "yqt.com.cnki.dao.IQKYDDao.getQKYDFileBasePath";
        return sqlSession.selectOne(statementId, realDbCode, false);
    }

    @Override
    public Boolean addBrowseRate(QKYDPo qkydPo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "yqt.com.cnki.dao.IQKYDDao.addBrowseRate";
        return sqlSession.executeUpdate(statementId, qkydPo);
    }

    @Override
    public Boolean addDownloadRate(QKYDPo qkydPo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "yqt.com.cnki.dao.IQKYDDao.addDownloadRate";
        return sqlSession.executeUpdate(statementId, qkydPo);
    }
}
